package com.qh.resourcehub.config;

import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.LocalDateTimeTypeHandler;
import org.apache.ibatis.type.MappedTypes;

import java.sql.Timestamp;
import java.time.LocalDateTime;

@MappedTypes(LocalDateTime.class)
public class CustomLocalDateTimeTypeHandler extends LocalDateTimeTypeHandler {
    public CustomLocalDateTimeTypeHandler() {
        super();
    }

    @Override
    public LocalDateTime getNullableResult(java.sql.ResultSet rs, String columnName) throws java.sql.SQLException {
        Timestamp timestamp = rs.getTimestamp(columnName);
        return timestamp != null ? timestamp.toLocalDateTime() : null;
    }
}
